import request from '@/utils/http';

// 问题相关API
export const questionApi = {
  // 创建问题
  createQuestion(data) {
    return request({
      url: '/Pass/question/create',
      method: 'post',
      data
    });
  },
  
  // 获取问题列表（带分页）
  getQuestionList(params) {
    return request({
      url: '/Pass/question/list',
      method: 'get',
      params: {
        pageNum: params.pageNum || 1,
        pageSize: params.pageSize || 10,
        questionType: params.questionType || '',
        keyword: params.keyword || '',
        sortBy: params.sortBy || 'hot'
      }
    });
  },
  
  // 获取问题详情
  getQuestionDetail(questionId) {
    return request({
      url: `/Pass/question/detail/${questionId}`,
      method: 'get'
    });
  },
  
  // 点赞/取消点赞问题
  likeQuestion(questionId, isLike) {
    return request({
      url: `/Pass/question/like/${questionId}`,
      method: 'post',
      params: {
        isLike
      }
    });
  },
  
  // 删除问题
  deleteQuestion(questionId) {
    return request({
      url: `/Pass/question/delete/${questionId}`,
      method: 'delete'
    });
  }
};

// 回答相关API
export const answerApi = {
  // 创建回答
  createAnswer(data) {
    return request({
      url: '/Pass/question/answer/create',
      method: 'post',
      data
    });
  },
  
  // 删除回答
  deleteAnswer(answerId) {
    return request({
      url: `/Pass/question/answer/delete/${answerId}`,
      method: 'delete'
    });
  },
  
  // 点赞/取消点赞回答
  likeAnswer(answerId, isLike) {
    return request({
      url: `/Pass/question/answer/like/${answerId}`,
      method: 'post',
      params: {
        isLike
      }
    });
  },
  
  // 点赞/取消点赞回复
  likeReply(answerId, isLike) {
    return request({
      url: `/Pass/question/answer/like/${answerId}`,
      method: 'post',
      params: {
        isLike
      }
    });
  }
};